header echoUARTToFile
{
	// This script shows how to log the serial port input pipe onto the log file...
	// It simply prints out any characters received on the serial port...
	// By Mauro Grassi...
}

script echoUARTToFile
{
	// open the serial port at 115200 bps, Tx on #D5 and Rx on #D4...
	@@openUART(#defaultUART, 115200, #D5, #D4);
	// open #D0 as a digital output, which we toggle to acknowledge reception of a character...
	@@openIO(#D0, #outputIO);
	// clear the log file for this script...
	clearFile "uartecho.txt";
	while(1)
	{
		if(@@newRxUART())
		{
			// store the last received character...
			$C=$$serial.lastRx;
			// output the character to the log file for this script...
			print char($C);
			// continue!
			// toggle the digital output!
			@@toggleIO(#D0);
		}

	}
}
		